package com.sbwebsocket.core.redis;

import com.sbwebsocket.core.redis.model.contants.WsMessageRedisKeyPrefix;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @Auther: GSJ
 * @Date: 2022/2/16
 * @Description:
 * @version: 1.0
 */
public class RedisModeUtil {

    @Autowired
    private StringRedisTemplate redisTemplate;

    /**
     * 根据clientIdentity获取服务器订阅key
     * @param clientIdentity
     * @return
     */
    public String getServerKey(String clientIdentity) {
        //todo: 此种方式用户量过大时，redis会生成大量的key
        return redisTemplate.opsForValue().get(WsMessageRedisKeyPrefix.CLIENT_SERVER + clientIdentity);
    }
}
